use std::collections::HashMap;

// 代码12-10

pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32>
{
    let mut map = HashMap::new();

    for i in 0..nums.len(){
        let complement = target -nums[i];

        if map.contains_key(&complement){
            return vec![i as i32, map[&complement] as i32];
        }
        
        map.insert(nums[i], i);
    }

    return  vec![];

}